clear
set more off

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"


cd "`path0'data\HumanCapital\"

use "`path0'data\HumanCapital\BL2013_MF1599_v2.0.dta" , clear

keep year country WBcode yr_sch 
rename WBcode countrycode
replace countrycode="GER" if countrycode=="DEU"
replace countrycode="ZAR" if countrycode=="COD"
replace countrycode="MDA" if countrycode=="ROM"
replace countrycode="ROM" if countrycode=="ROU"
replace countrycode="SCG" if countrycode=="SER"



save temp, replace

forvalues i=1950(5)2010 {
	use temp, clear
	keep if year==`i'
	drop year
	rename yr_sch yr_sch_`i'
	label var yr_sch_`i'   "Total years of schooling: Barro-Lee data: `var'"
	save temp_`i', replace
}

use temp_1950, clear
forvalues i=1955(5)2010 {
	joinby countrycode using temp_`i'
	
}

forvalues i=1950(5)2010 {
	erase temp_`i'.dta
	
}
	
erase temp.dta	
compress

cd "`path0'\Workfiles"

duplicates report countrycode

keep countrycode yr_sch_1970

save BarroLee_data_updated, replace
